package StudyCode.summary.BufferAndChannel;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadInputStreamStringBufferedReader {
	public static String inputStreamToString(final InputStream inputStream) {
		final BufferedReader br = new BufferedReader(new InputStreamReader(
				inputStream));
		final StringBuilder sb = new StringBuilder();

		try {
			while (br.ready()) {
				sb.append(br.readLine());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		return sb.toString();
	}
}
